package com.sys.SysTanks.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysTanks.domain.SysTanks;
import com.sys.SysTanks.service.ISysTanksService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 养殖桶Controller
 * 
 * @author sys
 * @date 2025-09-04
 */
@RestController
@RequestMapping("/SysTanks/SysTanks")
public class SysTanksController extends BaseController
{
    @Autowired
    private ISysTanksService sysTanksService;

    /**
     * 查询养殖桶列表
     */
    @PreAuthorize("@ss.hasPermi('SysTanks:SysTanks:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTanks sysTanks)
    {
        startPage();
        List<SysTanks> list = sysTanksService.selectSysTanksList(sysTanks);
        return getDataTable(list);
    }

    /**
     * 导出养殖桶列表
     */
    @PreAuthorize("@ss.hasPermi('SysTanks:SysTanks:export')")
    @Log(title = "养殖桶", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTanks sysTanks)
    {
        List<SysTanks> list = sysTanksService.selectSysTanksList(sysTanks);
        ExcelUtil<SysTanks> util = new ExcelUtil<SysTanks>(SysTanks.class);
        util.exportExcel(response, list, "养殖桶数据");
    }

    /**
     * 获取养殖桶详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysTanks:SysTanks:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysTanksService.selectSysTanksById(id));
    }

    /**
     * 新增养殖桶
     */
    @PreAuthorize("@ss.hasPermi('SysTanks:SysTanks:add')")
    @Log(title = "养殖桶", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTanks sysTanks)
    {
        sysTanksService.insertSysTanks(sysTanks);
        return success();
    }

    /**
     * 修改养殖桶
     */
    @PreAuthorize("@ss.hasPermi('SysTanks:SysTanks:edit')")
    @Log(title = "养殖桶", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTanks sysTanks)
    {
        return toAjax(sysTanksService.updateSysTanks(sysTanks));
    }

    /**
     * 删除养殖桶
     */
    @PreAuthorize("@ss.hasPermi('SysTanks:SysTanks:remove')")
    @Log(title = "养殖桶", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysTanksService.deleteSysTanksByIds(ids));
    }
}
